﻿using System.Configuration;

namespace MyPLC.Config
{
    public class AppConfig
    {
        
        /// <summary>
        /// 间隔300s同步一次
        /// </summary>
        public static int SyncSeconds
        {
            get
            {
                int def = 300;
                int s = 0;
                string value = ConfigurationManager.AppSettings["SyncSeconds"];
                value = string.IsNullOrWhiteSpace(value) ? "300" : value;
                return int.TryParse(value, out s) ? s : def;
            }
        }
        /// <summary>
        /// 间隔200ms同步一次
        /// </summary>
        public static int SyncMilliSeconds
        {
            get
            {
                int def = 200;
                int s = 0;
                string value = ConfigurationManager.AppSettings["SyncMilliSeconds"];
                value = string.IsNullOrWhiteSpace(value) ? "200" : value;
                return int.TryParse(value, out s) ? s : def;
            }
        }
        /// <summary>
        /// 偏移量
        /// </summary>
        public static decimal Offset
        {
            get
            {
                decimal def = 0M;
                decimal s = 0M;
                string value = ConfigurationManager.AppSettings["Offset"];
                value = string.IsNullOrWhiteSpace(value) ? "0" : value;
                return decimal.TryParse(value, out s) ? s : def;
            }
        }
    }
}
